Solving linear systems with Matlab

Solving linear systems of equations with Matlab consists of a few steps.

  1. Model your engineering problem as a system of linear equations. (NOTE: This is the hard part.)
  2. Rewrite your linear system in general form with unknowns on the left and known (constants) on the right side of the equations.
  3. [Optional] Write your linear system as a single Matrix Equation of the form: Ax=b
    Where A is a matrix of the coefficients of the unknowns of each equation and b is a column vector that contains the constants (right hand side of each equation).
  4. Enter the coefficient matrix in Matlab as A.
  5. Enter the right hand side data values of your equations as column vector b.
  6. Execute the Matlab matrix equation solve command: x = A\b

This will give you a vector variable of solutions x. The \ operator performs Gaussian elimination on the matrix equation. It is just that simple. Depending upon how many unknowns you have and thus how large your matrix is, the \ operation can involve an enormous amount of computation. However, you don’t have to be concerned about that. So long as you have mathematically modeled your problem correctly and entered the coefficient matrix, A, and data vector, b, correctly, Matlab will take care of the rest.